<?php
namespace Home\Controller;

use Think\Controller;
use Think\Auth;
class BaseController extends Controller
{
    public function _initialize()
    {
        $auth = new Auth();
        if(!$this->checkLogin()){
            $this->error('请先登录', U('User/login'));
        }else{
            $name = MODULE_NAME . '/' . CONTROLLER_NAME . '/' . ACTION_NAME;
            $uid = session('userinfo.emp_id');
            if(!$auth->check($name, $uid)) $this->error('您没有足够的权限', U('Index/index'));
        }
    }
    
    public function checkLogin()
    {
        $username = session('userinfo');
        return !empty($username);   
    }
    
}